import serial, time


def main():
    name = "/dev/ttyUSB0"
    interface = serial.Serial(name, baudrate=115200, timeout=2)
    # data = '132+213'
    # for i in data:
    #     if i != '+':
    #         interface.write(ord(i).to_bytes(1, 'big'))
    #         time.sleep(0.5)
    # interface.write(b'w')
    while True:
        s = interface.read_all()
        time.sleep(0.1)
        if len(s) and s == b'B':
            print(s)
            data = '132+213'
            for i in data:
                if i != '+':
                    time.sleep(0.5)
                    interface.write(ord(i).to_bytes(1, 'big'))


if __name__ == '__main__':
    main()
